<?php

namespace SummoIngenio\Sai\MatematicaBundle\Utility\Juego\P0;
use SummoIngenio\Sai\MatematicaBundle\Utility\Juego\JuegoBase;
define('CANT_PROBLEMAS', 5);
/**
 * Description of P01037
 *
 * @author SVM
 */

class P01037 extends JuegoBase {
  
  public function init() {
  
    $this->paleta = rand(0,2);  
	if($this->paleta == 2){
		$this->dulce = rand(0,2);
	}else{
		$this->dulce = rand(0,3);
	}
	if(7*$this->paleta+3*$this->dulce<=10){
	    $this->choco = rand(1,2);
	}else{
		if(7*$this->paleta+3*$this->dulce<=15){
			$this->choco = rand(0,1);
		}else{
			$this->choco = 0;
		}
	}
	
	$this->precios = array(3,7,5);
  }
  
  public function getPregunta() {
    return '';
  }
  public function getHtmlDesactivado() {	
    return $this->render('P0/P01037/desactivado', array(
        'dulce'   =>  $this->dulce,		
        'paleta'   =>  $this->paleta,
        'choco'   =>  $this->choco,
		'precios' => $this->precios,
      ));
  }
  
  public function getHtmlJugable() {
    return $this->render('P0/P01037/jugable', array(
        'dulce'   =>  $this->dulce,		
        'paleta'   =>  $this->paleta,
        'choco'   =>  $this->choco,
		'precios' => $this->precios,
      ));
  }
  
  public function getHtmlResuelto() {
    return $this->render('P0/P01037/resuelto', array(
        'dulce'   =>  $this->dulce,		
        'paleta'   =>  $this->paleta,
        'choco'   =>  $this->choco,
		'precios' => $this->precios,
      ));
  }
  
  public function verificarRespuesta($respuestaUsuario) {
     $rsp = true;
	 $cadena = $this->precios[0]+"*"+$this->dulce+"+"+$this->precios[1]+"*"+$this->paleta+"+"+$this->precios[2]+"*"+$this->choco;
	 if($respuestaUsuario->get('valor1')!=($this->precios[0]*$this->dulce+$this->precios[1]*$this->paleta+$this->precios[2]*$this->choco)){ 
	   $rsp=false;
	 } 
    $aRetornar = array(
      'respuesta' => $cadena,
      'correcta'  => $rsp,
    );
    return $aRetornar;
  }

  public function getJavascript() {
    $aRetornar = array(
      "tipo"      => "archivo",
      "contenido" => "P0/P01037.js"
    );
    return $aRetornar;
  }

  public function getCss() {
    $aRetornar = array(
      "tipo"      => "archivo",
      "contenido" => "P0/P01037.css"
    );
    return $aRetornar;
  }

  public function __sleep() {
    return array(
        'dulce',
        'paleta',		
        'choco',
		'precios',
    );
  }
}

?>